package com.ywk.base.concurrency.threadPool.myThreadPool;
import java.util.ArrayList;
import java.util.List;

/**
 * 测试类
 *
 * @Author yjian
 * @Date 15:37 2017/10/14
 **/
public class MyThreadPoolTest {


    public static void main(String[] args) {
        //获取线程池
        IMyThreadPool t = MyThreadPoolImpl.getThreadPool(20,100);
        //此时已经有20个线程在运行，等待抢占执行任务队列
        List<Runnable> taskList = new ArrayList<Runnable>();
        for (int i = 0; i < 100; i++) {
            taskList.add(new Task());
        }
        //增加执行任务
        t.execute(taskList);
        System.out.println(t);
        //销毁线程
        t.destroy();
        System.out.println(t);
    }

    static class Task implements Runnable {

        private static volatile int i = 1;

        @Override
        public void run() {
            System.out.println("当前处理的线程:" + Thread.currentThread().getName() + " 执行任务" + (i++) + " 完成");
        }
    }

}
